<!--suppress ALL -->
<template>
    <div class="page rdsp-fix-botttom-page createTrouble-page" data-page="createTrouble" style="z-index: 2;">
        <div class="link-page-nav">
            <a href="#" class="link" @click="$root.backToTab()">
                <i class="iconfont icon-zuo"></i>
            </a>
        </div>
        <div class="link-page-top" style="padding-bottom: 17px;">
            <div class="link-page-title">创建隐患</div>
        </div>
        <div class="page-content" style="padding-bottom: 25px;">
            <!--轮播上传图片-->
            <div id="keyAlarmPic_createTrouble_{{getNewId}}" style="margin: 10px 20px;"></div>
            <div class="form-hiddenDanger">
                <div class="rdsp-inner-content">
                    <div class="hiddenDanger-block">
                        <div class="left-title fl"><span class="must-fill">*</span>隐患描述</div>
                        <div class="right-con">
                            <textarea id="crTb_textarea_{{getNewId}}" class="right-con-textarea cancle-ios-write"
                                placeholder="请写清晰明了的描述现场情况有利于他人的处理"></textarea>
                            <div class="voice">
                                <div id="crTb_inputDetails_{{getNewId}}" class="voice-before">
                                    <i class="iconfont icon-yuyin1"></i>点击语音输入
                                </div>
                                <div class="voice-after" style="display: none">
                                    <div class="voice-after-time">
                                        <i class="iconfont icon-yuyin-copy"></i>
                                    </div>
                                    <div class="delete">
                                        <i class="iconfont icon-icon-shanchu-copy"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;"><span class="must-fill">*</span>所在单位</div>
                        <div class="right-con  has-arrow">
                            <div id="crTb_resUnit_{{getNewId}}" class="right-select">请选择所在单位</div>
                            <i id="crTb_resUnit_icon_{{getNewId}}" class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;"><span class="must-fill">*</span>所在建筑</div>
                        <div class="right-con  has-arrow">
                            <div id="trouble_bulid_{{getNewId}}" class="right-select">请选择所在建筑</div>
                            <i id="crTb_resUnit_icon_{{getNewId}}" class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                    <div class="hiddenDanger-block">
                        <div class="left-title fl">具体位置</div>
                        <div class="right-con">
                            <textarea id="crTb_textareaAds_{{getNewId}}" class="right-con-textarea cancle-ios-write"
                                placeholder="明确的描述能够确保他人快速定位隐患位置"></textarea>
                            <div class="voice">
                                <div id="crTb_inputAddress_{{getNewId}}" class="voice-before">
                                    <i class="iconfont icon-yuyin1"></i>点击语音输入
                                </div>
                                <div class="voice-after" style="display: none">
                                    <div class="voice-after-time">
                                        <i class="iconfont icon-yuyin-copy"></i>
                                    </div>
                                    <div class="delete">
                                        <i class="iconfont icon-icon-shanchu-copy"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;">相关资产</div>
                        <div class="right-con  has-arrow">
                            <div id="trouble_asset" class="right-select">请选择相关资产</div>
                            <i id="crTb_resUnit_icon" class="iconfont icon-zuo"></i>
                        </div>
                    </div> -->
                    <!-- <div @click="relatedAssets">111111</div> -->
                    <div class="hiddenDanger-block" @click="relatedAssets">
                        <div class="left-title fl" style="margin-left: 21px;">相关资产</div>
                        <div class="right-con  has-arrow">
                            <div id="trouble_asset_{{getNewId}}" class="right-select">请选择相关资产</div>
                            <i id="crTb_resUnit_icon_{{getNewId}}" class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                    <div class="hiddenDanger-block" @click="relatedEquipment">
                        <div class="left-title fl" style="margin-left: 21px;width: 100px;">相关物联设备</div>
                        <div class="right-con  has-arrow">
                            <div id="trouble_eq_{{getNewId}}" class="right-select">请选择相关物联设备</div>
                            <i id="crTb_resUnit_icon_{{getNewId}}" class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-hiddenDanger">
                <div class="rdsp-inner-content">
                    <div class="hiddenDanger-block">
                        <div class="left-title" style="margin-left: 21px;">责任指派</div>
                        <div id="crTb-id-hiddenDanger-block-item1_{{getNewId}}"
                            class="hiddenDanger-block-item block-active" @click="option_hiddenOrShow(5)">
                            <div id="crTb-id-hiddenDanger-block-circle1_{{getNewId}}"
                                class="hiddenDanger-block-circle circle-active"></div>
                            <span>选择指派人</span>
                        </div>
                        <div id="crTb-id-hiddenDanger-block-item2_{{getNewId}}" class="hiddenDanger-block-item"
                            @click="option_hiddenOrShow(1)">
                            <div id="crTb-id-hiddenDanger-block-circle2_{{getNewId}}" class="hiddenDanger-block-circle">
                            </div>
                            <span>选择责任人</span>
                        </div>
                        <div class="right-con" style="padding: 10px 20px; padding-bottom: 20px;display: none;">
                            <div style="width: 50%; float: left;" class="item-title-row">
                                <label class="item-radio item-content" @click="option_hiddenOrShow(5)"> <input
                                        name="troubleType" type="radio" data-type="1" value="5" checked="checked" /> <i
                                        style="border-radius: 18px;" class="icon icon-radio"></i>
                                    <div class="item-inner">
                                        <div class="item-title radio-for-me"
                                            style="position: absolute; width: 70px; top: 0px; left: 26px;">由他人指派
                                        </div>
                                    </div>
                                </label>
                            </div>
                            <div style="width: 50%; float: left;display: none;" class="item-title-row radio-for-ather">
                                <label class="item-radio item-content" @click="option_hiddenOrShow(1)"> <input
                                        name="troubleType" type="radio" data-type="2" value="1" /> <i
                                        style="border-radius: 18px;" class="icon icon-radio"></i>
                                    <div class="item-inner">
                                        <div class="item-title text-for-other"
                                            style="position: absolute; width: 70px; top: 0px; left: 28px;">由我指派
                                        </div>
                                    </div>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="rdsp-inner-content option-for-me" id="crTb_id_layout1_{{getNewId}}">
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;">隐患等级</div>
                        <div class="right-con  has-arrow">
                            <div id="crTb_level_{{getNewId}}" class="right-select">请选择隐患等级</div>
                            <i class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                </div>
                <div class="rdsp-inner-content option-for-me" id="crTb_id_layout2_{{getNewId}}">
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;">隐患类别</div>
                        <div class="right-con  has-arrow">
                            <div id="crTb_type_{{getNewId}}" class="right-select">请选择隐患类别</div>
                            <i class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                </div>
                <div class="rdsp-inner-content">

                </div>
                <div class="rdsp-inner-content">

                </div>
                <div class="rdsp-inner-content ">
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;" id="crTb_resPel_text_{{getNewId}}">责任人
                        </div>
                        <div class="right-con  has-arrow">
                            <div id="crTb_resPel_{{getNewId}}" class="right-select">请选择责任人</div>
                            <i class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                </div>
                <div class="rdsp-inner-content option-for-me" id="crTb_id_layout3_{{getNewId}}">
                    <div class="hiddenDanger-block">
                        <div class="left-title fl" style="margin-left: 21px;">整改期限</div>
                        <div class="right-con  has-arrow">
                            <div id="crTb_endTime_{{getNewId}}" class="right-select">请选择整改期限</div>
                            <i class="iconfont icon-zuo"></i>
                        </div>
                    </div>
                </div>
                <div class="rdsp-inner-content option-for-me" id="crTb_id_layout3_{{getNewId}}">
                    <div id="endTimeDays" class="d-flex ai-center" style="display: none;">
                        <div class="left-title fl" style="margin-left: 21px;font-weight: bold;">工作日</div>
                        <input class="input-text flex-1" type="number" placeholder="请输入工作日" />
                    </div>
                </div>
            </div>
            <div @click="crTb_submit" class="rdsp-fix-botttom" style="margin-top: 30px; margin-bottom: 39px;">创建隐患
            </div>
        </div>

    </div>
</template>
<style>
    .createTrouble-page .input-text {
        margin-right: 31px;
        height: 35px;
        font-size: 14px;
        border: none;
        text-align: right;
    }

    .input-text::-webkit-outer-spin-button,
    .input-text::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    .hiddenDanger-block-item {
        height: 40px;
        border-radius: 4px;
        margin: 10px 20px;
        border: 1px solid rgba(208, 208, 208, 1);
        color: #999999;
        line-height: 40px;
        padding-left: 20px;
    }

    .hiddenDanger-block-item .hiddenDanger-block-circle {
        width: 12px;
        height: 12px;
        border: 1px solid rgba(169, 169, 169, 1);
        border-radius: 50%;
        display: inline-block;
        margin-right: 15px;
    }

    .hiddenDanger-block-item.block-active {
        border: 1px solid rgba(36, 113, 202, 1);
        color: rgba(36, 113, 202, 1);
    }

    .hiddenDanger-block-item .hiddenDanger-block-circle.circle-active {
        background: rgba(36, 113, 202, 1);
    }

    /* #getunit {
        margin-left: 5px;
        margin-top: 5px;
        height: 34px;
        width: 90%;
        text-indent: 5px;
        font-size: 18px;
    } */

    .unit_topname {
        padding-left: 18px;
        padding-top: 5px;
        margin: auto;
        font-size: 14px;
        color: #222222;
    }

    .cus_wup {
        float: left;
        padding-left: 0px;
    }

    .inp_cus {
        width: 100%;
        height: 165px;
    }

    .up_cus {
        margin: 6px;
        position: relative;
        float: left;
        background-repeat: no-repeat;
        background-position: center;
        background-size: cover;
        position: relative;
    }

    .ul_cus {
        padding: 3px;
        float: left;
    }

    .cus {
        height: 100px;
        padding-left: 18px;
    }

    .line_wz {
        white-space: nowrap;
        display: inline-block;
        width: 92%;
        top: 15px;
        left: 18px;
        position: relative;
    }

    .btnupdate {
        font-size: 17px;
        color: #04a9ff;
    }

    .lefttext {
        padding-left: 0px;
        color: #333333 !important;
        width: 92%;
        white-space: nowrap;
        display: inline-block !important;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1;
        font-size: 14px;
    }

    .resizable {
        font-size: 15px;
        width: 100%;
        padding: 18px;
        min-height: 80px;
        max-height: 250px;
    }

    #file {
        font-size: 1px;
        top: 0px;
        left: 0px;
        opacity: 0;
        width: 100px;
        height: 100px;
        display: block;
        color: #999999;
    }

    .add_image {
        position: absolute;
        top: 8px;
        width: 100px;
        height: 100px;
    }

    #line_width {
        width: 100%;
        height: auto;
    }

    .del {
        width: 14px;
        height: 14px;
        right: 5px;
        position: absolute;
    }

    .button-fill {
        width: 91% !important;
        height: 44px !important;
        margin: 0 auto;
        background: linear-gradient(to top, #238afb, #40affe);
        line-height: 0px;
        font-size: 16px;
    }

    #kalarm .messagebar-attachments {
        border-bottom: 1px solid rgba(221, 221, 221, 0.5);
    }

    .select-right {
        width: 13px;
        height: 13px;
        background: url(./img/common/select.png);
        background-repeat: no-repeat;
        float: left;
        position: absolute;
        vertical-align: middle;
        background-size: 100%;
    }

    .demo-swiper .swiper-slide {
        font-size: 25px;
        font-weight: 300;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #fff;
        color: #333333;
    }

    .demo-swiper .swiper-slide {
        box-sizing: border-box;
        /* border: 1px solid #ddd; */
        background: #fff;
    }

    .demo-swiper {
        margin: 0px 0 35px;
        font-size: 18px;
        height: 200px;
    }

    .demo-swiper.demo-swiper-auto .swiper-slide {
        width: 85%;
    }

    .demo-swiper.demo-swiper-auto .swiper-slide:nth-child(2n) {
        width: 70%;
    }

    .demo-swiper.demo-swiper-auto .swiper-slide:nth-child(3n) {
        width: 30%;
    }

    .BMap_cpyCtrl {
        display: none;
    }

    .anchorBL {
        display: none;
    }

    .createTrouble_del {
        width: 14px;
        height: 14px;
        right: 7px;
        top: 3px;
        border-radius: 100px;
        position: absolute;
        background: url(./img/home/del_pic.png);
    }
</style>
<script>
    return {
        mounted() {
            var self = this;
            var $ = self.$;
            if (self.$route.params.detail == "-1") {
                self.hiddenDangerDesc = "";
                if (self.$route.params.taskId == "-1") {
                    self.currentTaskId = 0;
                } else {
                    self.currentTaskId = self.$route.params.taskId;
                }
                if (self.$route.params.pointId == "-1") {
                    self.currentPointId = 0;
                } else {
                    self.currentPointId = self.$route.params.pointId;
                }
                $("#crTb_textarea_" + self.getNewId).val("");
            } else {
                self.hiddenDangerDesc = self.$route.params.detail.replace(/[$]/g, '/');
                self.currentTaskId = self.$route.params.taskId;
                self.currentPointId = self.$route.params.pointId;
                console.log('self.currentPointId',self.currentPointId)
                console.log('self.currentTaskId',self.currentTaskId)
                if (self.hiddenDangerDesc != '') {
                    var hiddenDangerDesc = self.hiddenDangerDesc.split(",")[0];
                    var fbsName = self.hiddenDangerDesc.split(",")[1];
                    var fbsId = self.hiddenDangerDesc.split(",")[2]
                    var addrDesc = self.hiddenDangerDesc.split(",")[3];
                    $("#crTb_textarea_" + self.getNewId).val(hiddenDangerDesc);
                    $("#trouble_bulid_" + self.getNewId).html(fbsName);
                    self.chargeBuildId = fbsId;
                    $("#crTb_textareaAds_" + self.getNewId).val(addrDesc);
                } else {
                    $("#crTb_textarea_" + self.getNewId).val(self.hiddenDangerDesc);
                }
            }
        },
        data: function () {
            return {
                imageArr: [],
                picUrls: '',
                orgId: 0, //联网单位id
                troubleRank: 0, //等级id
                categoryId: 0, //类别id
                endTimeType: 0, //时间类型
                chargePersonName: '', //责任人
                chargeCompany: 0, //责任单位id
                chargeBuildId: 0, //建筑物id
                assetId: "", //资产id
                selectOptionIndex_asset: "",
                equipmentId: "", //设备id
                selectOptionIndex_eq: "",
                touBgrade: {}, //全部等级
                touBValueObj: {}, //全部类别
                userObj: {}, //联网单位下人员
                touBType: [],
                voiceFlag: false,
                troubleType: 5,
                currentTaskId: 0,
                currentPointId: 0,
                nineFcfId: '',
                buildName: "",
                getNewId: (new Date()).getTime(),
            }
        },
        methods: {
            backPage: function () {
                var self = this;
                var $ = self.$$;
                if (self.hiddenDangerDesc == "''") {
                    app.router.back();
                } else {
                    app.router.back(2);
                }
            },
            createTrouble: function () {
                app.router.navigate("/createTrouble/''/''/''/");
            },
            //跳转相关资产
            relatedAssets: function () {
                let self = this;
                if (self.chargeCompany != 0 && self.chargeBuildId != 0) {
                    app.router.navigate("/relatedAssets/" + self.chargeCompany + "/" + self.chargeBuildId + "/" +
                        self.buildName + "/");
                } else {
                    app.methods.showToastCenter('请选择单位和建筑');
                }

            },
            //接收资产信息
            receiveAssets: function (id, name) {
                let self = this;
                self.assetId = id;
                jQuery("#trouble_asset_" + self.getNewId).html(name);
            },
            //跳转物联设备
            relatedEquipment: function () {
                let self = this;
                if (self.chargeCompany != 0 && self.chargeBuildId != 0) {
                    app.router.navigate("/relatedEquipment/" + self.chargeCompany + "/" + self.chargeBuildId + "/" +
                        self.buildName + "/");
                } else {
                    app.methods.showToastCenter('请选择单位和建筑');
                }

            },
            //接收物联设备信息
            receiveEquipment: function (id, name) {
                let self = this;
                self.equipmentId = id;
                jQuery("#trouble_eq_" + self.getNewId).html(name);
            },
            //选择业主单位
            select_unit: function () {
                var self = this;
                loadSelectUnitFunc(function (data) {
                    if (self.chargeCompany == data.orgId) {
                        $("#crTb_resUnit_" + self.getNewId).removeClass("select_color");
                        $("#crTb_resUnit_" + self.getNewId).addClass("right-select");
                        $("#crTb_resUnit_" + self.getNewId).html("请选择责任单位");
                        $("#trouble_bulid_" + self.getNewId).html("请选择所在建筑");
                        self.chargeCompany = 0;
                    } else {
                        //重新选择单位后清除建筑物的选择
                        if (data.orgName != $("#crTb_resUnit_" + self.getNewId)[0].innerText) {
                            $("#trouble_bulid_" + self.getNewId).html("请选择所在建筑")
                        }
                        //选择单位赋值
                        $("#crTb_resUnit_" + self.getNewId).removeClass("right-select");
                        $("#crTb_resUnit_" + self.getNewId).addClass("select_color");
                        $("#crTb_resUnit_" + self.getNewId).html(data.orgName);

                        self.chargeCompany = data.orgId;
                    }
                }, self.chargeCompany);
            },
            //选择建筑
            select_build: function () {
                var self = this;
                if (self.chargeCompany) {
                    loadSelectBuildFun(self.chargeCompany, function (data) {
                        self.chargeBuildId = data.buildId;
                        self.buildName = data.buildName;
                        $("#trouble_bulid_" + self.getNewId).html(data.buildName);
                    });
                } else {
                    app.methods.showToastCenter('请先选择业主单位');
                }
            },
            //选择资产
            select_assets: function () {
                let self = this;
                let assetsArr = [];
                if (self.chargeCompany) {
                    if (self.chargeBuildId) {
                        Dao.getAListForApp({
                            categoryIds: -1,
                            queryType: 0,
                            organizationId: self.chargeCompany,
                            systemId: -1,
                            isUse: -1,
                            name: "",
                            fbsIds: self.chargeBuildId,
                        }, function (res) {
                            if (res && res.length > 0) {
                                for (let i = 0; i < res.length; i++) {
                                    let obj = {};
                                    obj.id = res[i].id;
                                    obj.name = res[i].name;
                                    assetsArr.push(obj);
                                }
                                selectOptionFn(assetsArr, function (data) {
                                    if (self.assetId != data.id) {
                                        self.assetId = data.id;
                                        $("#trouble_asset_" + self.getNewId).html(data.name);
                                    } else {
                                        self.assetId = 0;
                                        $("#trouble_asset_" + self.getNewId).html("请选择相关资产");
                                    }
                                    if (self.selectOptionIndex_asset != data.index) {
                                        self.selectOptionIndex_asset = data.index;
                                    } else {
                                        self.selectOptionIndex_asset = "";
                                    }
                                }, self.selectOptionIndex_asset);
                            } else {
                                app.methods.showToastCenter('暂无数据');
                            }
                        });
                    } else {
                        app.methods.showToastCenter('请关联建筑物');
                    }

                } else {
                    app.methods.showToastCenter('请先选择业主单位');
                }
            },
            //九小用户登录 获取九小用户消防设施
            getNineMarkData: function () {
                var self = this;
                var fcfIdArr = [];
                Dao.selectVenuesRelateInfo_ajax({
                    userName: userInfor.accountName,
                    deviceId: appKeyObj.deviceId,
                    venuesId: nineCode,
                    relateObjType: 1
                }, function (data) {
                    if (data && data.fcfsList.length > 0) {
                        for (var i = 0; i < data.fcfsList.length; i++) {
                            fcfIdArr.push(data.fcfsList[i].id);
                        }
                        self.nineFcfId = fcfIdArr.toString();
                    }
                }, false);
            },
            //选择设备
            select_eq: function () {
                let self = this;
                let eqsArr = [];
                if (self.chargeCompany) {
                    if (self.chargeBuildId) {
                        common.loading(1);
                        Dao.getmoreDectorStateList({
                            orgIds: self.chargeCompany,
                            fcfCategoryId: -1,
                            systemId: -1, //设备类别
                            fbsId: self.chargeBuildId,
                            fireTType: -1,
                            name: '',
                            fcfId: self.nineFcfId,
                            pageIndex: 0,
                            pageSize: 2000,
                        }, function (res, total) {
                            common.loading(0);
                            if (res && res.length > 0) {
                                for (let i = 0; i < res.length; i++) {
                                    let obj = {};
                                    obj.id = res[i].fcFacilitiesId;
                                    obj.name = res[i].fcFacilitiesName;
                                    eqsArr.push(obj);
                                }
                                selectOptionFn(eqsArr, function (data) {
                                    if (self.equipmentId != data.id) {
                                        self.equipmentId = data.id;
                                        $("#trouble_eq_" + self.getNewId).html(data.name);
                                    } else {
                                        self.equipmentId = 0;
                                        $("#trouble_eq_" + self.getNewId).html("请选择相关物联设备");
                                    }
                                    if (self.selectOptionIndex_eq != data.index) {
                                        self.selectOptionIndex_eq = data.index;
                                    } else {
                                        self.selectOptionIndex_eq = "";
                                    }
                                }, self.selectOptionIndex_eq);
                            } else {
                                app.methods.showToastCenter('暂无数据');
                            }
                        });
                    } else {
                        app.methods.showToastCenter('请先选择建筑物');
                    }
                } else {
                    app.methods.showToastCenter('请先选择业主单位');
                }
            },
            option_hiddenOrShow: function (type) {
                var self = this;
                self.chargePersonName = '';
                self.troubleType = type;
                //由我指派
                if (self.troubleType == 1) {
                    jQuery("#crTb_id_layout1_" + self.getNewId).show();
                    jQuery("#crTb_id_layout2_" + self.getNewId).show();
                    jQuery("#crTb_id_layout3_" + self.getNewId).show();
                    jQuery("#crTb_resPel_text_" + self.getNewId).html("责任人");
                    jQuery("#crTb_resPel_" + self.getNewId).html("请选择责任人");
                    jQuery("#crTb-id-hiddenDanger-block-item1_" + self.getNewId).removeClass("block-active");
                    jQuery("#crTb-id-hiddenDanger-block-item2_" + self.getNewId).addClass("block-active");
                    jQuery("#crTb-id-hiddenDanger-block-circle1_" + self.getNewId).removeClass("circle-active");
                    jQuery("#crTb-id-hiddenDanger-block-circle2_" + self.getNewId).addClass("circle-active");
                } else {
                    jQuery("#crTb_id_layout1_" + self.getNewId).hide();
                    jQuery("#crTb_id_layout2_" + self.getNewId).hide();
                    jQuery("#crTb_id_layout3_" + self.getNewId).hide();
                    jQuery("#crTb_resPel_text_" + self.getNewId).html("指派人");
                    jQuery("#crTb_resPel_" + self.getNewId).html("请选择指派人");
                    jQuery("#crTb-id-hiddenDanger-block-item1_" + self.getNewId).addClass("block-active");
                    jQuery("#crTb-id-hiddenDanger-block-item2_" + self.getNewId).removeClass("block-active");
                    jQuery("#crTb-id-hiddenDanger-block-circle1_" + self.getNewId).addClass("circle-active");
                    jQuery("#crTb-id-hiddenDanger-block-circle2_" + self.getNewId).removeClass("circle-active");
                }
            },
            voidStart_detail: function () {
                var self = this;
                self.voiceFlag = true;
                native.startVoice("crTb_textarea_" + self.getNewId, true);
            },
            voidStart_address: function () {
                var self = this;
                self.voiceFlag = true;
                native.startVoice("crTb_textareaAds_" + self.getNewId, false);
                /*self.voidStart_address();*/
            },
            initTbPiker: function () {
                var self = this;
                let selectOptionIndex1 = null;
                let selectOptionType = null;
                self.option_hiddenOrShow(self.troubleType);
                //责任人
                jQuery("#crTb_resPel_" + self.getNewId).click(function (e) {
                    if (self.chargeCompany == 0) {
                        app.methods.showToastCenter('请选择责任单位');
                    } else {
                        getFourTypeUser(self.chargeCompany, function (data) {
                            if (self.chargePersonName == data.id) {
                                $("#crTb_resPel_" + self.getNewId).removeClass("select_color");
                                $("#crTb_resPel_" + self.getNewId).addClass("right-select");
                                jQuery("#crTb_resPel_" + self.getNewId).html("请选择" + (self
                                    .troubleType == 1 ? "责任人" : "指派人"));
                                self.chargePersonName = '';
                            } else {
                                $("#crTb_resPel_" + self.getNewId).removeClass("right-select");
                                $("#crTb_resPel_" + self.getNewId).addClass("select_color");
                                jQuery("#crTb_resPel_" + self.getNewId).html(data.name);
                                self.chargePersonName = data.id;
                            }
                            if (selectOptionIndex1 != data.index) {
                                selectOptionIndex1 = data.index;
                                selectOptionType = data.type;
                            } else {
                                selectOptionIndex1 = "";
                                selectOptionType = 1;
                            }
                        }, selectOptionIndex1, selectOptionType);
                    }
                });
                //等级
                Dao.getDict({
                    code: 49
                }, function (data) {
                    if (data.dictValueObj && data.dictValueObj.length > 0) {
                        var arr = [];
                        var result = data.dictValueObj;
                        for (var i = 0; i < result.length > 0; i++) {
                            var obj = {};
                            obj.id = result[i].dictKey;
                            obj.name = result[i].dictValue;
                            arr.push(obj);
                        }
                        //隐患等级
                        let selectOptionIndex = null;
                        jQuery("#crTb_level_" + self.getNewId).click(function (e) {
                            selectOptionFn(arr, function (data) {
                                if (self.troubleRank == data.id) {
                                    $("#crTb_level_" + self.getNewId).removeClass(
                                        "select_color");
                                    $("#crTb_level_" + self.getNewId).addClass(
                                        "right-select");
                                    jQuery("#crTb_level_" + self.getNewId).html("请选择隐患等级");
                                    self.troubleRank = 0;
                                } else {
                                    $("#crTb_level_" + self.getNewId).removeClass(
                                        "right-select");
                                    $("#crTb_level_" + self.getNewId).addClass(
                                        "select_color");
                                    jQuery("#crTb_level_" + self.getNewId).html(data.name);
                                    self.troubleRank = data.id;
                                }
                                if (selectOptionIndex != data.index) {
                                    selectOptionIndex = data.index;
                                } else {
                                    selectOptionIndex = "";
                                }
                            }, selectOptionIndex);
                        });
                    }
                });
                //类型
                Dao.getDict({
                    code: 50
                }, function (data) {
                    if (data.dictValueObj && data.dictValueObj.length > 0) {
                        var arr = [];
                        var json = JSON.parse(data.dictValueObj[0].dictValue);
                        for (var i = 0; i < json.length > 0; i++) {
                            var obj = {};
                            obj.id = json[i].id;
                            obj.name = json[i].text;
                            arr.push(obj);
                        }
                        let selectOptionIndex = null;
                        //隐患类型
                        jQuery("#crTb_type_" + self.getNewId).click(function (e) {
                            selectOptionFn(arr, function (data) {
                                if (self.categoryId == data.id) {
                                    $("#crTb_type_" + self.getNewId).removeClass(
                                        "select_color");
                                    $("#crTb_type_" + self.getNewId).addClass(
                                        "right-select");
                                    jQuery("#crTb_type_" + self.getNewId).html("请选择隐患类型");
                                    self.categoryId = 0;
                                } else {
                                    $("#crTb_type_" + self.getNewId).removeClass(
                                        "right-select");
                                    $("#crTb_type_" + self.getNewId).addClass(
                                        "select_color");
                                    jQuery("#crTb_type_" + self.getNewId).html(data.name);
                                    self.categoryId = data.id;
                                }
                                if (selectOptionIndex != data.index) {
                                    selectOptionIndex = data.index;
                                } else {
                                    selectOptionIndex = "";
                                }
                            }, selectOptionIndex, 1);
                        });
                    }
                });
                //整改期限
                var dateType = [];
                var dateResylt = [];
                dateResylt.push({
                    "id": 1,
                    "text": "24小时"
                });
                dateResylt.push({
                    "id": 2,
                    "text": "5个工作日"
                });
                dateResylt.push({
                    "id": 3,
                    "text": "10个工作日"
                });
                dateResylt.push({
                    "id": 4,
                    "text": "30个工作日"
                });
                dateResylt.push({
                    "id": 5,
                    "text": "3个月内"
                });
                dateResylt.push({
                    "id": 6,
                    "text": "半年内"
                });
                dateResylt.push({
                    "id": 7,
                    "text": "自定义"
                });
                for (var i = 0; i < dateResylt.length > 0; i++) {
                    var obj = {};
                    obj.id = dateResylt[i].id;
                    obj.name = dateResylt[i].text;
                    dateType.push(obj);
                }
                let selectOptionIndex = null;
                jQuery("#crTb_endTime_" + self.getNewId).click(function (e) {
                    selectOptionFn(dateType, function (data) {
                        if (self.endTimeType == data.id) {
                            $("#crTb_endTime_" + self.getNewId).removeClass("select_color");
                            $("#crTb_endTime_" + self.getNewId).addClass("right-select");
                            jQuery("#crTb_endTime_" + self.getNewId).html("请选择整改期限");
                            self.endTimeType = 0;
                            $('#endTimeDays').hide()
                        } else {
                            jQuery("#crTb_endTime_" + self.getNewId).html(data.name);
                            $("#crTb_endTime_" + self.getNewId).removeClass("right-select");
                            $("#crTb_endTime_" + self.getNewId).addClass("select_color");
                            self.endTimeType = data.id;
                            if (self.endTimeType == 7) {
                                $('#endTimeDays').show()
                            } else {
                                $('#endTimeDays').hide()
                            }
                        }
                        if (selectOptionIndex != data.index) {
                            selectOptionIndex = data.index;
                        } else {
                            selectOptionIndex = "";
                        }
                    }, selectOptionIndex);
                });
                //绑定语音输入隐患描述
                jQuery("#crTb_inputDetails_" + self.getNewId).click(function (e) {
                    //第二个参数是否需要保存语音
                    if (getClickEnabel(4000)) {
                        app.view.current.el.f7View.router.currentPageEl.f7Component.voidStart_detail()
                    };
                });
                jQuery("#crTb_inputAddress_" + self.getNewId).click(function (e) {
                    if (getClickEnabel(4000)) {
                        app.view.current.el.f7View.router.currentPageEl.f7Component.voidStart_address()
                    }
                });
            },
            //语音输入回调
            voiceCollectionData: function (voiceStr, componentId) {
                var text = $("#" + componentId)[0].value;
                if (!voiceStr || "" === voiceStr.trim()) {
                    app.methods.showToastCenter("未能识别您说的语音,请重试。");
                } else {
                    $("#" + componentId).val(text + voiceStr);
                }
            },
            // 创建隐患
            crTb_submit: function () {
                var self = this;
                common.loading(1);
                if (self.voiceFlag) {
                    self.voiceFlag = false;
                    native.saveTheVoiceFile(self.chargeCompany * 1);
                } else {
                    if (getClickEnabel(4000)) {
                        self.callbackVoiceFile("", 0);
                    }
                }
                common.loading(0);
            },
            callbackVoiceFile: function (voiceUrl, wavLength) {
                var self = this;
                self.picUrls = self.imageArr.join(",");
                if (self.picUrls == "") {
                    app.methods.showToastCenter('请添加隐患照片');
                    return;
                }
                var text1 = $("#crTb_textarea_" + self.getNewId).val();
                if (text1 == "") {
                    app.methods.showToastCenter('请填写隐患描述');
                    return;
                }
                if (self.chargeCompany == 0) {
                    app.methods.showToastCenter("请选择单位");
                    return;
                }
                if (self.chargeBuildId == 0) {
                    app.methods.showToastCenter("请选择建筑物");
                    return;
                }
                //判断是否为我指派：troubleType==1
                if (self.troubleType == 1) {
                    if (self.troubleRank == 0) {
                        app.methods.showToastCenter("请选择隐患等级");
                        return;
                    }
                    if (self.categoryId == 0) {
                        app.methods.showToastCenter("请选择隐患类别");
                        return;
                    }
                    if (self.chargePersonName == '') {
                        app.methods.showToastCenter("请选择责任人");
                        return;
                    }
                    if (self.endTimeType == 0) {
                        app.methods.showToastCenter("请选择整改期限");
                        return;
                    }
                    if (self.endTimeType == 7 && $('#endTimeDays input').val() == '') {
                        app.methods.showToastCenter("请填写自定义整改期限");
                        return;
                    }
                    let params={
                        id: 0,
                        orgId: self.chargeCompany,
                        fbsId: self.chargeBuildId, //建筑物
                        relateAssetsIds: self.assetId, //资产
                        relateFcfIds: self.equipmentId, //物联设备
                        categoryId: self.categoryId,
                        gradeId: self.troubleRank,
                        chargePerson: self.chargePersonName,
                        picUrls: self.picUrls,
                        hiddenDangerDesc: $("#crTb_textarea_" + self.getNewId).val(),
                        addrDesc: $("#crTb_textareaAds_" + self.getNewId).val(),
                        createAccount: userInfor.accountName,
                        endTimeType: self.endTimeType == 7 ? 0 : self.endTimeType,
                        hiddenDangerVoice: voiceUrl,
                        voiceLength: wavLength,
                        status: 1,
                        maintainTaskId: self.currentTaskId ? parseInt(self.currentTaskId) : "",
                        maintainPointId: self.currentPointId ? parseInt(self.currentPointId) : "",
                    }
                    if(self.endTimeType == 7){
                        params.days=$('#endTimeDays input').val()
                    }
                    Dao.saveHidDanger(params, function (data) {
                        common.loading(0);
                        app.methods.showToastCenter('隐患已提报');
                        app.methods.backToTab();
                        //   app.view.current.el.f7View.router.currentPageEl.f7Component.refreshCurrentPageData();
                    });
                } else {
                    if (self.chargePersonName == '') {
                        app.methods.showToastCenter("请选择指派人");
                        return;
                    }
                    Dao.saveHidDanger({
                        id: 0,
                        orgId: self.chargeCompany,
                        fbsId: self.chargeBuildId, //建筑物
                        relateAssetsIds: self.assetId, //资产
                        relateFcfIds: self.equipmentId, //物联设备
                        managerPerson: self.chargePersonName,
                        picUrls: self.picUrls,
                        hiddenDangerDesc: $("#crTb_textarea_" + self.getNewId).val(),
                        addrDesc: $("#crTb_textareaAds_" + self.getNewId).val(),
                        createAccount: userInfor.accountName,
                        hiddenDangerVoice: voiceUrl,
                        voiceLength: wavLength,
                        status: 5,
                        maintainTaskId: self.currentTaskId ? parseInt(self.currentTaskId) : "",
                        maintainPointId: self.currentPointId ? parseInt(self.currentPointId) : "",
                    }, function (data) {
                        common.loading(0);
                        app.methods.showToastCenter('隐患已提报');
                        app.methods.backToTab();
                        // if(self.hiddenDangerDesc==""){
                        //     app.router.back();
                        // }else{
                        //     app.router.back(2);
                        // }
                        // app.view.current.el.f7View.router.currentPageEl.f7Component.refreshCurrentPageData();
                    });
                }
            },
            getOrganizationId: function () {
                var self = this;
                var $ = self.$;
                let unitListDatas = JSON.parse(sessionStorage.getItem('unitListData'))
                $("#crTb_resUnit_" + self.getNewId).empty();
                $("#crTb_resUnit_" + self.getNewId).append(unitListDatas[0].name);
                self.chargeCompany = userInfor.organizationIds;
                $("#crTb_resUnit_icon_" + self.getNewId).hide();
            },
        },
        on: {
            pageInit: function (e, page) {
                var self = this;
                var $ = self.$;
                // jQuery(".form-hiddenDanger .rdsp-inner-title").click(function (e) {
                //     jQuery(e.currentTarget).parent().toggleClass("show");
                //     jQuery(e.currentTarget).siblings(".rdsp-inner-content").slideToggle();
                // });
                self.voiceFlag = false;
                self.imageArr = [];
                if (userInfor.isMuilUnitUser == 0) { //单
                    $("#crTb_resUnit_" + self.getNewId).empty();
                    $("#crTb_resUnit_" + self.getNewId).append(userInfor.org.name);
                    self.chargeCompany = single_Orgid;
                    $("#crTb_resUnit_icon_" + self.getNewId).hide();
                } else {
                    let organizationId = userInfor.organizationIds.split(',')
                    if (organizationId.length > 1) {
                        //选择单位
                        $("#crTb_resUnit_" + self.getNewId).click(function () {
                            self.select_unit();
                        });
                    } else {
                        self.getOrganizationId()
                    }

                }
                //选择建筑物
                $("#trouble_bulid_" + self.getNewId).click(function () {
                    self.select_build();
                });
                //选择资产
                // $("#trouble_asset").click(function() {
                //     self.select_assets();
                // });
                //选择物联设备
                // $("#trouble_eq").click(function() {
                //     self.select_eq();
                // });
                self.initTbPiker();
                //初始化上传
                upLoadImagesCompt(jQuery("#keyAlarmPic_createTrouble_" + self.getNewId), function (pic, isAdd) {
                        let _pic = common.addWatermark(pic)
                        if (isAdd == "add") {
                            self.imageArr.unshift(_pic);
                        } else {
                            let index = self.imageArr.indexOf(_pic);
                            self.imageArr.splice(index, 1);
                        }
                    }, true, 9, 'createTrouble_container_' + self.getNewId, 'createTrouble_pick_' + self
                    .getNewId, '', true);
            },
        }

    }
</script>
<style scoped>
    #crTb_textarea,
    #crTb_textareaAds {
        padding-left: 14px;
        padding-right: 14px;
        padding-top: 10px;
        font-size: 14px;
    }

    .text-for-other {
        position: absolute;
        width: 71px;
        left: 27px;
        top: 0px;
    }

    .radio-for-ather {
        position: absolute;
        left: 95px;
        top: 0px;
    }

    .radio-for-me {
        position: absolute;
        width: 66px;
        left: 32px;
        top: 0px;
    }

    .select_color {
        text-align: right;
        padding-right: 17px;
        color: #333;
    }

    .cus {
        height: 100px;
        padding-left: 18px;
        border-bottom: 0px;
    }

    .cus_wup {
        padding-left: 0px;
    }

    .ul_cus {
        padding: 3px;
        position: absolute;
    }

    .up_cus {
        width: 74px;
        height: 73px;
        display: inline-block;
        float: left;
        margin: 4px;
        margin-top: 7px;
        background: url(./img/home/upload_pic.png);
    }

    .inp_cus {
        width: 79px;
        height: 79px;
    }

    #line_width {
        width: 100%;
        height: auto;
        white-space: nowrap;
        float: left;
        overflow-y: hidden;
    }

    #line_width ul {
        display: inline-block;
    }

    .createTrouble_del {
        width: 14px;
        height: 14px;
        right: 7px;
        top: 3px;
        border-radius: 100px;
        position: absolute;
        background: url(./img/home/del_pic.png);
    }

    .messagebar-attachments {
        padding: 0px !important;
        padding-left: 18px;
        padding-top: 10px;
    }

    .page-content {
        padding-top: 60px !important;
    }
</style>